package com.ruoyi.bizsys.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;

import com.ruoyi.common.utils.DateUtils;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 产品信息对象 product_info
 *
 * @author african-loan
 * @date 2021-12-30
 */

@Data
public class ProductInfo extends BaseEntity  implements Serializable {
    private static final long serialVersionUID = 1L;


    /**
     * 序号
     */

    @Excel(name = "${comment}", readConverterExp = "序号")
    @TableId(type = IdType.AUTO)
    private Long id;


    /**
     * 产品代码
     */

    @Excel(name = "产品代码")
    private String productCode;


    /**
     * 产品名称
     */

    @Excel(name = "产品名称")
    private String productName;


    /**
     * 产品范畴
     */

    @Excel(name = "产品范畴")
    private String productType;

    /**产品对应用户的等级**/
    private String creditRating;

    /**
     * 期数
     */

    @Excel(name = "期数")
    private Integer periodNum;


    /**
     * 单位
     */

    @Excel(name = "单位")
    private String unit;


    /** 产品展示利率 */
    @Excel(name = "产品展示利率")
    private BigDecimal showInterestRate;

    /** 展示服务费率 */
    @Excel(name = "展示服务费率")
    private BigDecimal showServiceRate;

    /** 是否支持延期产品0不支持1支持 */
    @Excel(name = "是否支持延期产品0不支持1支持")
    private Integer isDeferred;

    /** 产品金融标签,逗号隔开 */
    @Excel(name = "产品金融标签,逗号隔开")
    private String tags;

    /** 延期最大天数 */
    @Excel(name = "延期最大天数")
    private Integer deferredMaxDays;



    /**
     * 利(息)率
     */

    @Excel(name = "利(息)率")
    private BigDecimal interestRate;


    /**
     * 服务费率
     */

    @Excel(name = "服务费率")
    private BigDecimal serviceFee;


    /**
     * 趸交
     */

    @Excel(name = "趸交")
    private String isSinglePayment;


    /**
     * 授信比例
     */

    @Excel(name = "授信比例")
    private BigDecimal creditScale;


    /**
     * 最低贷款额度
     */

    @Excel(name = "最低贷款额度")
    private BigDecimal minQuota;


    /**
     * 最高贷款额度
     */

    @Excel(name = "最高贷款额度")
    private BigDecimal maxQuota;


    /**
     * 生效起始日期
     */

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "生效起始日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date startDate;


    /**
     * 生效结束日期
     */

    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "生效结束日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date endDate;


    /**
     * 滞纳金日费率
     */

    @Excel(name = "滞纳金日费率")
    private BigDecimal dateLateFee;


    /**
     * 滞纳金按日收费宽限期（天数）
     */

    @Excel(name = "滞纳金按日收费宽限期", readConverterExp = "天=数")
    private Integer lateFeeGracePeriod;


    /**
     * 滞纳金计算最大天数
     */

    @Excel(name = "滞纳金计算最大天数")
    private Integer lateFeeMaxDays;


    /**
     * 状态
     */

    @Excel(name = "状态")
    private String state;


    /**
     * 创建时间
     */

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "状态", width = 30, dateFormat = "yyyy-MM-dd")
    private Date createTime;


    /**
     * 是否默认产品 Y是；N否
     */

    @Excel(name = "是否默认产品 Y是；N否")
    private String defult;

    public LoanOrder generateLoanOrder(LoanOrder loanOrder) {
        loanOrder.setRepayDate(DateUtils.getFewDay(this.getPeriodNum()));
        loanOrder.setDateLateFee(this.getDateLateFee());
        loanOrder.setServiceFeeRate(this.getServiceFee());
        loanOrder.setLateFeeMaxDays(this.getLateFeeMaxDays());
        loanOrder.setFkProductId(this.getId());
        loanOrder.setInterestRate(this.getInterestRate());
        loanOrder.setMaxQuota(this.getMaxQuota());
        loanOrder.setMinQuota(this.getMinQuota());
        loanOrder.setIsSinglePayment(this.getIsSinglePayment());
        loanOrder.setLateFeeGracePeriod(this.getLateFeeGracePeriod());
        loanOrder.setPeriodNum(this.getPeriodNum());
        loanOrder.setProductName(this.getProductName());
        loanOrder.setUnit(this.getUnit());
        return loanOrder;
    }
}